layui.define(["jquery", "utils", "filters", "conf", "constants"], function (exports) {
    var $ = layui.$,
        utils = layui.utils,
        filters = layui.filters,
        conf = layui.conf,
        constants = layui.constants;

    function Widget() {
    }

    Widget.prototype = {
        constructor: Widget,

        /**
         * @author: ares
         * @date: 2021/3/25 16:27
         * @description: 生成性别单选项
         * @returns {HTMLElement}
         */
        createSexRadio: function () {
            var $fragment = $(document.createDocumentFragment());
            $fragment.append('<input type="radio" name="sex" value="male" title="男" checked>' +
                '<input type="radio" name="sex" value="female" title="女">');
            return $fragment;
        },
        /**
         * @author: ares
         * @date: 2021/3/25 16:29
         * @description: 生成患者类型下拉选项
         * @param {string}name  select的name和id属性值
         * @param {object}config    配置
         * @returns {HTMLElement}
         */
        createPatientClassifySelect: function (name, config) {
            return utils.createSelect(name, constants.patientClassifies, constants.patientClassifies[0].k, config);
        },

        /**
         * @author: ares
         * @date: 2021/3/26 11:19
         * @description: 生成病患类型颜色标记
         * @returns {HTMLElement}
         */
        createPatientClassifyColorMark: function () {
            var $fragment = $(document.createDocumentFragment());
            $.each(constants.patientClassifies, function (index, item) {
                $fragment.append('<span class="patient-classify-color ares-m" style="color: ' + item.color + ';"><i class="fa-circle"></i> ' + item.v + '</span>');
            });
            return $fragment;
        },

        /**
         * @author: ares
         * @date: 2021/3/25 16:36
         * @description: 生成医保类型单选项
         * @returns {HTMLElement}
         */
        createInsuranceTypeRadio: function () {
            return utils.createRadio('insuranceType', constants.insuranceTypes, constants.insuranceTypes[0].k);
        },

        /**
         * @author: ares
         * @date: 2021/3/31 10:17
         * @description: 生成患者基本信息
         * @param {jquery dom}$wrap   患者信息容器
         * @param {object}data
         * @returns {*|HTMLElement}
         */
        createPatientBaseInfo: function ($wrap, data) {
            var $fragment = $(document.createDocumentFragment());
            $fragment.append('<b class="ares-mr-lg">患者编号：' + data.number || '-' + '</b>')
            $fragment.append('<b class="ares-mr-lg">姓名：' + data.patient.name + '</b>')
            $fragment.append('<b class="ares-mr-lg">性别：' + filters.sexFormat(data.patient.sex) + '</b>')
            $fragment.append('<b class="ares-mr-lg">年龄：' + filters.ageFormat(data.patient.birthday) + '</b>')
            $fragment.append('<b class="ares-mr-lg">医保类型：' + filters.insuranceTypeFormat(data.insurance_type) + '</b>')
            if ($wrap) {
                $wrap.empty().append($fragment);
            } else {
                return $fragment
            }
        },

        /**
         * @author: ares
         * @date: 2021/3/25 16:36
         * @description: 训练状态标记
         * @returns {HTMLElement}
         */
        createTrainStatusRemark: function () {
            var $fragment = $(document.createDocumentFragment());
            $.each(constants.trainStatus, function (index, item) {
                $fragment.append('<span class="ares-ml"><i class="fa-stop" style="color: ' + item.color + ';"></i>' + item.v + '</span>');
            });
            return $fragment;
        },
    };

    var widget = new Widget();

    exports("widget", widget);
});
